<template>
  <div>
  <h2>管理员登陆</h2>
    <table class="table table-bordered">
      <tbody>
      <tr>
        <td align="right">账号</td>
        <td>
          <input type="text" v-model="info.username">
        </td>
      </tr>
      <tr>
        <td align="right">密码</td>
        <td>
          <input type="password" v-model="info.password">
        </td>
      </tr>
      <tr>
        <td align="right"></td>
        <td>
          <input type="button" value="登陆" class="btn btn-success" @click="login">
        </td>
      </tr>
      </tbody>
    </table>
  </div>
</template>

<script setup lang="ts">
import {ref,reactive,onMounted} from 'vue'
import {useRouter,useRoute} from 'vue-router'
import axios from "axios";
import moment from "moment";

const router = useRouter();
const route = useRoute();
let info:any = reactive({
  username:'',
  password:''
})

const login = () => {
  if(info.username==""){
    alert("账号不能为空");
    return;
  }
  if(info.password==""){
    alert("密码不能为空");
    return;
  }

  axios({
    url:'/api/Homes/Login',
    method:'get',
    params:info
  })
  .then(res=>{
    console.log(res);
    if(res.data==-1){
      alert("没有该账号");
      return;
    }
    if(res.data==-2){
      alert("密码错误");
      return;
    }
    else{
      alert("登陆成功");
      return;
    }
  })
      .catch((err)=>{

      })
}

</script>

<style scoped>

</style>